home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / tcp / rxfingerd.lha / rx.fingerd
Text File  |  1996-11-10  |  2KB  |  62 lines

  1. /*
  2.  *   Arexx Finger Daemon With Connection Logging
  3.  *   -------------------------------------------
  4.  *
  5.  * - Make sure this script has the S bit set and copy it to
  6.  *   "AmiTCP:serv/rx.fingerd"
  7.  * - Change the entry for finger in AmiTCP:db/inetd.conf to:
  8.  *   "finger    stream      tcp dos bin - rx AmiTCP:serv/rx.fingerd"
  9.  *
  10.  * This script is based in part on a more basic script that I found
  11.  * last year - original author unknown. I have modified it to work
  12.  * correctly with both finger client and telnet connections, and made
  13.  * several other small alterations.
  14.  *
  15.  * Philip Stokes <phil@stokes.demon.co.uk> 08/11/96
  16.  */
  17.  
  18. CR = '0d'x
  19. log = "UULib:fingerlog"  /* Path to logfile */
  20.  
  21. options results
  22. address AMITCP  'QUERY CONNECTIONS';info = result
  23. do conn = 1 to 10
  24.   hexad = word(info, conn*8-2)
  25.   port = x2d(word(info, conn*8-3))
  26.   state = word(info, conn*8)
  27.   if (port = 79 & hexad ~= 0 & state = 4) then do
  28.     address = x2d(substr(hexad, 1, 2)) || "." || x2d(substr(hexad, 3, 2))
  29.     address = address || "." || x2d(substr(hexad, 5, 2)) || "."
  30.     address = address || x2d(substr(hexad, 7, 2))
  31.     open(rslv, 'APIPE:AmiTCP:bin/resolve ' address, R)
  32.     address = word(readln(rslv), 3);close(rslv)
  33.     tolog = date(E) "  " time() "  " address
  34.     if ~exists(log) then do
  35.       call open(lg, log, W);writeln(lg, tolog)
  36.     end
  37.     else do
  38.       open(lg, log, A);writeln(lg, tolog)
  39.     end
  40.   end
  41. end
  42. call writeln(stdout,'Hello '||address||': Your connection is being logged.')
  43. arg = compress(readln(stdin),CR)
  44. arg = compress(arg,'`')
  45. select
  46.   when index(arg,'@') =1 then do
  47.     parse var arg '@' host
  48.     user = host
  49.   end
  50.   when index(arg,'@') >1 then do
  51.     parse var arg user '@' host
  52.   end
  53.   otherwise user = arg
  54. end
  55. if user = '' then do
  56.   address COMMAND 'AmiTCP:bin/finger'
  57. end
  58. else do
  59.   address COMMAND 'AmiTCP:bin/finger' user
  60. end
  61. exit
  62.